{% extends "layouts/base.html" %}
{% load navtag %}
{% block nav %}
  {% nav "liuyan" %}
  {{ block.super }}
{% endblock %}
{% block content %}
  <div class="white-box">
    <form class="form-horizontal">
      <input type="hidden" value='{{ csrf_token  }}', name="csrfmiddlewaretoken">
      <div class="form-group">
        <div class="col-md-12">
          <input class="form-control" type="text" placeholder="如何称呼您" name="name">
        </div>
      </div>
      <div class="form-group">
        <div class="col-md-12">
          <input class="form-control" type="text" placeholder="您的联系方式" name="phone">
        </div>
      </div>
      <div class="form-group">
        <div class="col-md-12">
          <textarea class="form-control" rows="20" placeholder="您的反馈意见" name="content"></textarea>
        </div>
      </div>
      <div class="text-right">
        <a class="btn btn-block btn-success save">反馈</a>
      </div>
    </form>
  </div>
  <script>
  $('.save').click(function(){
    $.ajax({
      url: '/feedback/create',
      type: 'post',
      data: $(this).closest('form').serialize(),
      dataType: 'json',
      success: function(data){
        if(data.success == 'true'){
           alert_msg(data.msg);
        } else {
          check_error($('input[name=name]'), data, 'name', '您的称呼：');
          check_error($('input[name=phone]'), data, 'phone', '您的联系方式：');
          check_error($('textarea[name=content]'), data, 'content', '您的反馈意见：');
        }
      }
    });
  });
  </script>
{% endblock %}